import { reactive, ref } from "vue-demi";
import { Help } from '../types/index'
import { Speed } from './UseField'
import { Fraction } from './UseFraction'
let HelpData: Help = reactive({
  src: '../../src/assets/11.png',
  IsShow: false,
  height: 400,
  Height: 0,
  Difficulty: 0,//困难等级
})
let elData = reactive({
  value1: 0,
  value2: 0,
  value3: false,
  percentage: 0,
  percentage1: 0,
  colors: [
    { color: '#f56c6c', percentage: 20 },
    { color: '#e6a23c', percentage: 40 },
    { color: '#5cb87a', percentage: 60 },
    { color: '#1989fa', percentage: 80 },
    { color: '#6f7ad3', percentage: 100 }
  ],
  colors1: [
    { color: '#f56c6c', percentage1: 20 },
    { color: '#e6a23c', percentage1: 40 },
    { color: '#5cb87a', percentage1: 60 },
    { color: '#1989fa', percentage1: 80 },
    { color: '#6f7ad3', percentage1: 100 }
  ]
})

//获取当前速度
function SpeedPercentage() {
  if (Speed.value <= 50) {
    elData.percentage = 100
  } else if (Speed.value <= 80) {
    elData.percentage = 80
  } else if (Speed.value <= 110) {
    elData.percentage = 60
  } else if (Speed.value <= 140) {
    elData.percentage = 40
  } else if (Speed.value <= 200) {
    elData.percentage = 20
  } else if (Speed.value <= 260) {
    elData.percentage = 10
  }
}
//获取当前困难等级
function GetDifficulty() {
  if (HelpData.Difficulty >= 80) {
    elData.percentage1 = 100
  } else if (HelpData.Difficulty >= 70) {
    elData.percentage1 = 80
  } else if (HelpData.Difficulty >= 60) {
    elData.percentage1 = 60
  } else if (HelpData.Difficulty >= 45) {
    elData.percentage1 = 40
  } else if (HelpData.Difficulty >= 35) {
    elData.percentage1 = 20
  } else if (HelpData.Difficulty >= 20) {
    elData.percentage1 = 10
  } else if (HelpData.Difficulty < 20) {
    elData.percentage1 = 0
  }
}
export {
  HelpData,
  elData,
  SpeedPercentage,
  GetDifficulty
}